package cn.itcast.hotel.web;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hotel")
public class HotelController {
    @Autowired
    private IHotelService hotelService;

    /**
     * 根据用户输入的条件查询对应酒店
     * @param params
     * @return
     */
    @PostMapping("/list")
    public PageResult list(@RequestBody RequestParams params){
        PageResult pageResult = hotelService.getHotels(params);
        return pageResult;
    }

    /**
     * 用户输入框显示提示信息
     * @param prefix
     * @return
     */
    @GetMapping("suggestion")
    public List<String> getSuggestions(@RequestParam("key") String prefix) {
        return hotelService.getSuggestions(prefix);
    }

}
